<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fns.tld" prefix="fns" %>
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <jsp:include page="/resources/inc/head.jsp" />
</head>
<form class="layui-form" id="_form">
    <table class="layui-table">
        <colgroup>
            <col width="150">
            <col width="100">
            <col width="100">
            <col width="200">
        </colgroup>
        <thead>
        <tr>
            <th>姓名</th>
            <th>是否缺席</th>
            <th>是否迟到</th>
            <th>培训表现</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${trainUsers}" var="user">
            <tr>
                <td>${user.realname}</td>
                <td>
                    <input type="checkbox" name="isJoin" userId="${user.id}" lay-skin="primary"
                           <c:if test="${user.is_join}">checked</c:if>
                    >
                </td>
                <td>
                    <input type="checkbox" name="isLate" userId="${user.id}" lay-skin="primary"
                           <c:if test="${user.is_late}">checked</c:if>
                    >
                </td>
                <td>
                    <input type="input" name="expression" userId="${user.id}" value="${user.expression}">
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <div class="layui-form-item">
        <div class="layui-input-block" style="float: right">
            <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
        </div>
    </div>
</form>
<body>

<jsp:include page="/resources/inc/pageFooter.jsp" />
<script>
    $(function () {
        var trainUsers = $(${trainUsers});
        FormCommon.initForm({
            url: "${basePath}/oa/hr/train/updateTrainUsers",
            subContentType: "json",
            editData: function (data) {
                var trainUserList = [];
                if (trainUsers.length >= 1) {
                    trainUsers.each(function (index, user) {
                        var isJoinInput = $("input[name='isJoin'][userId=" + user.id + "]");
                        var isLateInput = $("input[name='isLate'][userId=" + user.id + "]");
                        var expressionInput = $("input[name='expression'][userId=" + user.id + "]");
                        var trainUser = {};
                        trainUser.id = user.id;
                        trainUser.isJoin = isJoinInput.is(':checked');
                        trainUser.isLate = isLateInput.is(':checked');
                        trainUser.expression = expressionInput.val();
                        trainUserList.push(trainUser);
                    });
                }
                return trainUserList;
            }
        });

    });
</script>
</body>
</html>
